import jdk.swing.interop.SwingInterOpUtils;

import java.sql.*;
import java.util.Scanner;

public class jdbcex {
    public static void main(String[] args) throws SQLException {
//用户输入用户名和密码，判断是否能登录
        Scanner sc = new Scanner(System.in);
        System.out.print("请输入用户名:");
        String s = sc.nextLine();

        System.out.println("请输入密码:");
        String c = sc.nextLine();
//获取连接
        Connection connection = DriverManager.getConnection("jdbc:mysql://localhost/dept1","root","1234");

//执行sql

        Statement statement = connection.createStatement();
        String sql1 = "select * from text";
        ResultSet resultSet = statement.executeQuery(sql1);

//获取表的列数
//        ResultSetMetaData metaData = resultSet.getMetaData();
//        int columnCount = metaData.getColumnCount();

//处理表
        if (resultSet.next()){
            System.out.println("登录成功");
        }else {
            System.out.println("登录失败");
        }
        resultSet.close();
        statement.close();
        connection.close();
    }
}